package com.lagou.service.impl;


import com.lagou.service.HelloService;
import org.apache.dubbo.config.annotation.Service;

import java.util.concurrent.ThreadLocalRandom;

@Service
public class HelloServiceImpl implements HelloService {

    @Override
    public String methodA(String name) {
        sleep();
        System.out.println("methodA:" + name);
        return "methodA:" + name;
    }

    @Override
    public String methodB(String name) {
        sleep();
        System.out.println("methodB:" + name);
        return "methodB:" + name;
    }

    @Override
    public String methodC(String name) {
        sleep();
        System.out.println("methodC:" + name);
        return "methodC:" + name;
    }

    private void sleep(){
        ThreadLocalRandom random = ThreadLocalRandom.current();
        int number = random.nextInt(100);
        if (number > 0){
            try {
                Thread.sleep(number);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

}